home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1997
/
MacHack 1997.toast
/
Hacks
/
Hacks ’95
/
Menu Controls
/
ToolsMenu.h
< prev
next >
Wrap
Text File
|
1995-06-24
|
4KB
|
144 lines
// Copyright © 1994-95 by Apple Computer, Inc. All rights reserved.
// ToolsMenu.h
#ifndef __TOOLSMENU__
#define __TOOLSMENU__
#ifndef __UTEAROFFMENUVIEW__
#include "UTearOffMenuView.h"
#endif
#ifndef __UVIEW__
#include "UView.h"
#endif
//--------------------------------------------------------------------------------------------------
class TShape;
//--------------------------------------------------------------------------------------------------
// Constants
#define kShapesInPalette 5
#define kNoToolSelection -1
//--------------------------------------------------------------------------------------------------
// CLASS TToolsMenu - the Tools tear-off menu
//--------------------------------------------------------------------------------------------------
class TToolsMenu : public TTearOffMenuView
{
MA_DECLARE_CLASS;
public:
TToolsMenu(); // Constructor
void IToolsMenu(ResNumber menuID);
};
//--------------------------------------------------------------------------------------------------
// CLASS TToolsPalette - the Tools palette used in the tools tear-off menu and
// the tools floating window
//--------------------------------------------------------------------------------------------------
class TToolsPalette : public TView
{
MA_DECLARE_CLASS;
public:
TToolsPalette(); // Constructor
void IToolsPalette(TDocument* itsDocument, TView* itsSuperView);
// • Screen display
virtual void DoSetCursor(const VPoint& localPoint, RgnHandle cursorRegion); // Override
virtual void Draw(const VRect& area); // Override
void SelectNewTool(short whichTool);
// • Mousing
virtual void DoMouseCommand(VPoint& theMouse,
TToolboxEvent* event,
CPoint hysteresis); // Override
virtual void TrackFeedback(TrackPhase aTrackPhase,
const VPoint& anchorPoint,
const VPoint& previousPoint,
const VPoint& nextPoint,
Boolean mouseDidMove,
Boolean turnItOn); // Override
// • Misc
inline short GetCurrTool() { return fCurrTool; };
inline short GetSelectedTool() { return fSelectedTool; };
short fCurrTool;
short fOldTool;
private:
short fSelectedTool;
CRect fChoiceArray[kShapesInPalette+1]; // bounds of each square in palette
void FrameTool(CRect toolRect);
void Toggle(short theTool);
};
//--------------------------------------------------------------------------------------------------
// CLASS TToolSelectCmd - this tracker tracks in:
// - the tools floating window
// - the tools palette in the document window
// - the tools tear-off menu
//--------------------------------------------------------------------------------------------------
class TToolSelectCmd : public TTearOffMenuViewTracker
{
MA_DECLARE_CLASS;
public:
TToolSelectCmd(); // Constructor
void IToolSelectCmd(TToolsPalette* theToolsPalette,
TToolsPalette* theMenuToolsPalette,
TToolsPalette* theFloatingToolsPalette,
VPoint theMouse);
// Must keep a reference to both the current TToolsPalette view that we're tracking in
// and the TToolsPalette view that is in the floating window
virtual TTracker* TrackMouse(TrackPhase aTrackPhase,
VPoint& anchorPoint,
VPoint& previousPoint,
VPoint& nextPoint,
Boolean mouseDidMove); // Override
virtual void TrackFeedback(TrackPhase aTrackPhase,
const VPoint& anchorPoint,
const VPoint& previousPoint,
const VPoint& nextPoint,
Boolean mouseDidMove,
Boolean turnItOn); // Override
virtual Boolean IsDoneTracking(); // Override
virtual void DoIt(); // Override
virtual void UndoIt(); // Override
virtual void RedoIt(); // Override
private:
TToolsPalette* fMenuToolsPalette;
TToolsPalette* fFloatingToolsPalette;
short fTool;
Boolean fExitTracking;
};
// • Utilities
TToolsPalette* GetToolsPalette();
//----------------------------------------------------------------------------------------
// Globals defined in ToolsMenu.cp:
extern TToolsMenu* gToolsMenu;
extern TWindow* gToolsPaletteWindow;
// Getter and setter for shapes list
extern void SetShapeInArray(TShape* shape);
extern TShape* GetShapeInArray(short shapeID);
extern short GetNumberOfShapes();
//----------------------------------------------------------------------------------------
#endif